package aspect;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {
    @Pointcut("execution(* com.zzxy.spring5.service..*.*(..))")
    public void myPoinCut(){
    }
    @Before("myPoinCut()")
    public void myBefor(JoinPoint jp) {
       // System.out.println(jp.getSignature().getName());
        System.out.println("before...");
    }
    @After("myPoinCut()")
    public void myAfter(JoinPoint jp){
      //  System.out.println(jp.getSignature().getName());
        System.out.println("after...");
    }
    @AfterReturning(value = "myPoinCut()",returning = "ret")
    public void myAfterReturing(JoinPoint jp,Object ret){
        //System.out.println(jp.getSignature().getName());
        System.out.println("my after returning ..."+ret);
    }
    @AfterThrowing(value ="myPoinCut()",throwing = "e")
    public void myThrowing(JoinPoint jp,Throwable e){
        System.out.println(jp.getSignature().getName());
        System.out.println("my throwing ..."+e.getMessage());
    }
    @Around("myPoinCut()")
    public Object Object (ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("my around before ...");
        Object obj = pjp.proceed();
        System.out.println("my around after ...");
        return obj;
    }
}
